1
general::
One is in grave difficulty or near death. For example, She knew her number was up when she saw the look on her supervisor's face, or He looks terrible; I think his number's up. In the earliest use of this phrase, in the early 1800s, number referred to an unfavorable lottery number, but in other citations it could be any number whereby one is identified, such as the number on a military dog tag.
American Heritage Idioms